<template>
  <div class="visitor-notVisited">
    <div class="search-group">
      <div class="input-wrap">
        <div class="label">所属行业:</div>
        <div class="input-item">
          <a-select ref="select" allowClear v-model="queryParam.industryInformationId" placeholder="请选择所属行业">
            <a-select-option v-for="(item, index) in informationList" :key="index" :value="item.id">
              {{ item.informationName }}
            </a-select-option>
          </a-select>
        </div>
      </div>

      <div class="input-wrap">
        <div class="label">单位名称:</div>
        <div class="input-item">
          <a-input :maxLength="30" clearable v-model="queryParam.companyName" placeholder="请输入单位名称" />
        </div>
      </div>

      <div class="input-wrap">
        <div class="label">责任民警姓名:</div>
        <div class="input-item">
          <a-input
            :maxLength="30"
            clearable
            v-model="queryParam.principalPoliceUserName"
            placeholder="请输入责任民警姓名"
          />
        </div>
      </div>

      <div class="btn-wrap">
        <a-button class="searchBtn" @click="searchQuery()" type="primary"> 搜索 </a-button>
        <a-button class="resetBtn" @click="searchReset()" type="primary"> 重置 </a-button>
      </div>
    </div>

    <div>
      <a-table
        :bordered="true"
        rowKey="companyMessageId"
        class="tableList"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        @change="handleTableChange"
      >
        <template v-slot:action="records">
          <span class="operation deatil-color" v-has="'check-record:detail'" @click="detailHandle(records)"
            >检查记录
          </span>
        </template>
      </a-table>
    </div>
  </div>
</template>
<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { comMethods } from '@/mixins/comMethods'
import startEndTime from '@/components/startEndTime'
import { mapState } from 'vuex'
export default {
  name: 'visitor-notVisited',
  components: { startEndTime },
  mixins: [JeecgListMixin, comMethods],
  computed: {
    ...mapState({
      isPoliceAgencyId: (state) => state.user.isPoliceAgencyId,
    }),
  },
  watch: {
    isPoliceAgencyId(v) {
      this.queryParam.policeAgencyId = v.id ? v.id : ''
      this.searchQuery()
    },
  },
  data() {
    return {
      url: {
        list: '/company/message/check_page',
      },
      columns: [
        {
          title: '序号',
          align: 'center',
          width: 100,
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        {
          title: '所属派出所',
          dataIndex: 'policeAgencyId_dictText',
          ellipsis: true,
          align: 'center',
        },
        {
          title: '单位名称',
          dataIndex: 'companyName',
          ellipsis: true,
          align: 'center',
        },
        {
          title: '所属行业',
          dataIndex: 'industryInformationId_dictText',
          ellipsis: true,
          align: 'center',
        },
        {
          title: '责任民警',
          dataIndex: 'principalPoliceUserName',
          ellipsis: true,
          align: 'center',
        },
        {
          title: '检查总次数',
          dataIndex: 'checkCount',
          ellipsis: true,
          align: 'center',
        },
        {
          title: '合格次数',
          dataIndex: 'checkQualifiedCount',
          ellipsis: true,
          align: 'center',
        },
        {
          title: '不合格次数',
          dataIndex: 'checkFailedCount',
          ellipsis: true,
          align: 'center',
        },
        {
          title: '操作',
          scopedSlots: { customRender: 'action' },
          align: 'center',
        },
      ],
    }
  },
  methods: {
    detailHandle(records) {
      let params = { companyMessageId: records.companyMessageId }
      this.$router.push({ path: '/company/checkRecord/checkDetail', query: { params } })
    },
  },
}
</script>
